home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / moonstonemadness.swf / scripts / __Packages / MoonStoneObstacle.as < prev    next >
Encoding:
Text File  |  2007-09-27  |  1.6 KB  |  60 lines

  1. class MoonStoneObstacle extends SideScroller.StaticObject
  2. {
  3.    var nPercent;
  4.    var bObjectBlock;
  5.    var bObjectSpecial;
  6.    var mcRef;
  7.    function MoonStoneObstacle(__mcRef, __oLayer, _nPercent)
  8.    {
  9.       super(__mcRef,__oLayer);
  10.       if(_nPercent == undefined)
  11.       {
  12.          _nPercent = 100;
  13.       }
  14.       this.nPercent = _nPercent;
  15.       this.bObjectBlock = false;
  16.       this.bObjectSpecial = true;
  17.       this.setState("Idle");
  18.    }
  19.    function onHitSpecial(__oRef)
  20.    {
  21.       if(this.CurrentState == "Idle")
  22.       {
  23.          if(TakGround(__oRef).IsInHeadSwing)
  24.          {
  25.             this.ParentLayer.doAddListener(this);
  26.             Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"ItemHit.mp3");
  27.             if(Library.Utils.MoreMath.getRandomRange(1,100) < this.nPercent)
  28.             {
  29.                var _loc3_ = this.ParentLayer.doAttachVisual("Dynamic_MoonStone");
  30.                _loc3_._x = this.Coord.x;
  31.                _loc3_._y = this.Coord.y;
  32.                _global.LevelManager.Instance.doAddMoonStone(_loc3_);
  33.             }
  34.             this.setState("Explode");
  35.             this.doLockState();
  36.          }
  37.       }
  38.    }
  39.    function doDestroy()
  40.    {
  41.       this.ParentLayer.doRemoveListener(this);
  42.       super.doDestroy();
  43.    }
  44.    function doExplode()
  45.    {
  46.       if(this.isStateComplete())
  47.       {
  48.          if(!this.mcRef.bStateAfterExplosion)
  49.          {
  50.             this.doDestroy();
  51.          }
  52.          else
  53.          {
  54.             this.doForcedSetState("ExplodedIdle");
  55.             this.ParentLayer.doRemoveListener(this);
  56.          }
  57.       }
  58.    }
  59. }
  60.